﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Newtonsoft.Json;
using System.IO;

namespace Torch.WL.Web.CleanChina
{
    public partial class json : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            
            string jsonText = TextBox1.Text; 

            JsonReader reader = new JsonReader(new StringReader(jsonText));

            Response.Write("<table><tr><td>TokenType</td><td>ValueType</td><td>Value</td></tr>"); 

            while (reader.Read())
            {
                Response.Write("<tr><td>" + reader.TokenType + "</td><td>" + WriteValue(reader.ValueType) + "</td><td>" + WriteValue(reader.Value)+"</td></tr>");

            }
            Response.Write("</table>"); 

        }


        string WriteValue(object obj)
        {
            if (obj == null) return "null";

            return obj.ToString();
        }

    }
}